package com.learning.platform.dto;

import java.time.LocalDateTime;
import java.util.List;

public class SearchResponse {
    private Long id;
    private String type; // COURSE, TAG, POST
    private String title;
    private String name;
    private String description;
    private String content;
    private String url;
    private Double score;
    private String coverUrl;
    private String teacherName;
    private Double averageRating;
    private Integer reviewCount;
    private Integer enrollmentCount;
    private Double price;
    private List<TagResponse> tags;
    private Integer courseCount;
    private String username;
    private Integer answerCount;
    private Integer viewCount;
    private LocalDateTime createdAt;

    // Constructors
    public SearchResponse() {}

    // Static factory methods
    public static SearchResponse fromCourse(Long id, String title, String description, String coverUrl, 
                                          String teacherName, Double averageRating, Integer reviewCount, 
                                          Integer enrollmentCount, Double price, List<TagResponse> tags) {
        SearchResponse response = new SearchResponse();
        response.setId(id);
        response.setType("COURSE");
        response.setTitle(title);
        response.setDescription(description);
        response.setCoverUrl(coverUrl);
        response.setTeacherName(teacherName);
        response.setAverageRating(averageRating);
        response.setReviewCount(reviewCount);
        response.setEnrollmentCount(enrollmentCount);
        response.setPrice(price);
        response.setTags(tags);
        return response;
    }

    public static SearchResponse fromTag(Long id, String name, String description, Integer courseCount) {
        SearchResponse response = new SearchResponse();
        response.setId(id);
        response.setType("TAG");
        response.setName(name);
        response.setDescription(description);
        response.setCourseCount(courseCount);
        return response;
    }

    public static SearchResponse fromPost(Long id, String title, String content, String username, 
                                        Integer answerCount, Integer viewCount, LocalDateTime createdAt) {
        SearchResponse response = new SearchResponse();
        response.setId(id);
        response.setType("POST");
        response.setTitle(title);
        response.setContent(content);
        response.setUsername(username);
        response.setAnswerCount(answerCount);
        response.setViewCount(viewCount);
        response.setCreatedAt(createdAt);
        return response;
    }

    // Getters and Setters
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public Double getScore() {
        return score;
    }

    public void setScore(Double score) {
        this.score = score;
    }

    public String getCoverUrl() {
        return coverUrl;
    }

    public void setCoverUrl(String coverUrl) {
        this.coverUrl = coverUrl;
    }

    public String getTeacherName() {
        return teacherName;
    }

    public void setTeacherName(String teacherName) {
        this.teacherName = teacherName;
    }

    public Double getAverageRating() {
        return averageRating;
    }

    public void setAverageRating(Double averageRating) {
        this.averageRating = averageRating;
    }

    public Integer getReviewCount() {
        return reviewCount;
    }

    public void setReviewCount(Integer reviewCount) {
        this.reviewCount = reviewCount;
    }

    public Integer getEnrollmentCount() {
        return enrollmentCount;
    }

    public void setEnrollmentCount(Integer enrollmentCount) {
        this.enrollmentCount = enrollmentCount;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public List<TagResponse> getTags() {
        return tags;
    }

    public void setTags(List<TagResponse> tags) {
        this.tags = tags;
    }

    public Integer getCourseCount() {
        return courseCount;
    }

    public void setCourseCount(Integer courseCount) {
        this.courseCount = courseCount;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public Integer getAnswerCount() {
        return answerCount;
    }

    public void setAnswerCount(Integer answerCount) {
        this.answerCount = answerCount;
    }

    public Integer getViewCount() {
        return viewCount;
    }

    public void setViewCount(Integer viewCount) {
        this.viewCount = viewCount;
    }

    public LocalDateTime getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(LocalDateTime createdAt) {
        this.createdAt = createdAt;
    }
}

